ABCpdf AddImageUrl method
Re-invent ASP.NET Hosting Community
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



ABCpdf AddImageUrl method Expand / Collapse
Author
Message
Posted 3/13/2006 1:45:00 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/1/2007 4:05:22 PM
Posts: 5, Visits: 2

Before I get too far along in developing a solution, I need to know if the AddImageUrl method of ABCpdf is permitted on these servers?  The security settings have to be relaxed enough to allow it (that's all I know at this point). 

If not, I will have to complete the HTML rendering engine I'm working on, but this would save me hours of effort.

Thanks!

Post #266
Posted 3/13/2006 1:59:00 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Administrators
Last Login: 7/19/2006 11:19:00 AM
Posts: 19, Visits: 1

Hello,

Unfortunately, at this time the security policy in place prevents the AddImageUrl method of ABCPdf.



Re-invent Technologies LLC

Post #267
Posted 3/13/2006 2:14:00 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/1/2007 4:05:22 PM
Posts: 5, Visits: 2

I was afraid you would say that.  When I complete the HTML p****r for translating HTML documents to PDF with ABCpdf without using the AddImageUrl method, I'll post some comments about how it works here.

Thanks for the quick reply!

Post #269
Posted 3/22/2006 4:11:00 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/1/2007 4:05:22 PM
Posts: 5, Visits: 2

The HTML conversion program I made takes an HTML page with some additional attributes on the TD elements and converts it to a PDF using ABCpdf without using the AddImageUrl method and staying within the security settings of the server.

Basically it loads the file into an XmlDocument (after converting ' ' to string.Empty since XmlDocument does not understand that string) and iterates over the nodes.  The assumption is that the bulk of the page is a table that describes the pdf document layout.  Since the file is p****d top to bottom, the 'TopDown' attribute of ABCpdf must be set to true.  Then it looks for a table node (only one was needed for my solution) and iterates over the tr then td nodes.  I also needed the ability to set the background color (for the 'paper' of my pdf).  Important portions of the code are below.

P****Style extracts information from a 'style' property of the element.  The 'GetSafe...Attribute' methods encapsulate the handling of the attribute not existing and the last parameter is the default value to use in that case.  The 'Convert...' methods are used to translate the english words displayed by the user into hex values - this could be accomplished as the value of the select elements, but I needed some additional flexibilty fo the integration I was performing with another site (www.misterpaddy.com).  I used the 'AddHtml' method to allow for editing of text by the user with font size and color information in HTML format (similar to the editor used for posting on this forum).

After the XmlDocument xmlDocument was loaded and the ABCpdf Doc doc was created:

doc.TopDown = true;

XmlNode tableNode = xmlDocument.SelectSingleNode("//table");

if (tableNode != null)

{

cellpadding = GetSafeIntAttribute("cellpadding", tableNode, 0);

cellspacing = GetSafeIntAttribute("cellspacing", tableNode, 0);

int pageWidth = GetSafeIntAttribute("width", tableNode, -1);

int pageHeight = GetSafeIntAttribute("height", tableNode, -1);

doc.MediaBox.Width = pageWidth;

doc.MediaBox.Height = pageHeight;

doc.Rect.String = doc.MediaBox.String;

doc.Color.String = this.ConvertHexToByteString(ConvertNamedColorsToHex(this.ddlPaperColor.SelectedItem.ToString()));

doc.FillRect(); //Sets the 'paper' color

style = this.GetSafeStringAttribute("style", tableNode, string.Empty);

P****Style(style, ref backgroundImage, ref height, ref width, ref fontSize, ref bold, ref color, ref italic, ref fontFamily, ref backgroundColor, ref underline, ref strikeOut, ref overline, ref superScript, ref subScript, ref lineBottom);

foreach(XmlNode trNode in tableNode.SelectNodes("tr"))

{

//Set defaults

currentX = 0; //Used to determine the current left side of the Rect

string vAlign = this.GetSafeStringAttribute("valign", trNode, "top");

string backgroundColorTr = this.GetSafeStringAttribute("bgcolor", trNode, backgroundColor);

double trHeight = 0;

doc.Rect.Top = currentY;

currentY += trHeight;

doc.Rect.Bottom = currentY;

doc.FontSize = fontSize;

foreach(XmlNode tdNode in trNode.SelectNodes("td"))

{

...

if (vAlign == "top")

{

doc.VPos = 0.0;

}

else if (vAlign == "middle")

{

doc.VPos = 0.5;

}

else

{

doc.VPos = 1.0;

}

doc.AddHtml(textOut);

...

The rest of the method loads any images referenced by 'img' tags and converts them to one of two colors (I needed to allow two printing inks only).

If you have any questions I'd be happy to answer them in this forum.

Post #273
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Administrator, Re-invent (Paul), Re-invent (Nick)

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 7:04am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.031. 12 queries. Compression Disabled.


Copyright 2007 Re-invent Technologies LLC All Rights Reserved.