Page Border for PDF page.

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Converter for .NET (v1)  /  Page Border for PDF page.

DynamicPDF Converter for .NET (v1) Forum

 Mar 05 2014 6:45 AM
Hi,

am generating PDF from XML and HTML.
so using DynamicPDF.Generator am able create page border for pdf
and using DynamicPDF.Conversion unable to create page border for pdf.

so pages generated using Generator had page border and pages generated using Conversion dll had not page border.

how can i create page border for pages generated from HTML data using Conversion dll.

Below is code

//Dynamicpdf.Generator
MemoryStream ms = new MemoryStream();
document.Draw(ms);
byte[] buffer = null;
buffer = ms.ToArray();

//combination of Generator and Conversion dll
byte[] a = ceTe.DynamicPDF.Conversion.Converter.ConvertHtmlString("HTML data", new ceTe.DynamicPDF.Conversion.HtmlConversionOptions(true), buffer);

Response.BinaryWrite(a);
 Mar 05 2014 10:00 AM
Posted by a ceTe Software moderator
Hello,

When you say "page border" do you mean a solid line around the page or a margin (space) around the page?

If you need to set margins when using the Converter, you can use HtmlConversionOptions class and set the BottomMargin, TopMargin, LeftMargin and RightMargin properties. 

Thanks,
ceTe Software Support Team.
 Mar 05 2014 10:43 PM
Yes
I want solid line around the page.
 Mar 06 2014 12:32 PM
Posted by a ceTe Software moderator
Hello,

Yes, you can add page border to the converted PDF using our DynamicPDF Merger for .NET product. You will need to convert the other file types to PDF using Converter and then add page border to it using Merger product. Below is the sample code for it.

ConversionOptions options = new ConversionOptions(ceTe.DynamicPDF.Conversion.PageSize.Letter, ceTe.DynamicPDF.Conversion.PageOrientation.Portrait, 50);
byte[] byteData = Converter.Convert(@"C:\Temp\Test.txt", options);
//Adding page border to the PDF using merger.
PdfDocument pdf = new PdfDocument(byteData);
MergeDocument document = new MergeDocument();
document.Append(pdf);
//Looping through the pages in the document for adding page border using Rectangle page element.
for (int i = 0; i < document.Pages.Count; i++)
{
  Page page = document.Pages[i];
  float width = page.Dimensions.Body.Width - (100);
  float height = page.Dimensions.Body.Height - (100); ;
  Rectangle rectangle = new Rectangle(50, 50, width, height);
 page.Elements.Add(rectangle);
}
document.Draw(@"C:\Temp\MyDocument.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 7:56 AM.