Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

SVG to PDF

$
0
0
Hi Team,

I am trying to create a PDF with header and footer and a content.
Header - Will have a text.
Footer - Will have an Image aligned to right
Content - will have the SVG.

I was able to generate the header and footer.
But the SVG file width is more than the width of my PDF. How can shrink my SVG so that it fits my pdf doc width.

Below is the code which creates the pdf.
I have attached my svg file for your reference.

string headerText = GetHeaderTextForPDF(model, downloadableFileName);
 Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
 Aspose.Pdf.Generator.Section sec = pdf.Sections.Add();
sec.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;
sec.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.A4Width;
sec.IsLandscape = true;
sec.PageInfo.PageBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.Bottom | (int)Aspose.Pdf.Generator.BorderSide.Top, 0.2F);
Aspose.Pdf.Generator.HeaderFooter hf = new Aspose.Pdf.Generator.HeaderFooter(sec);
 hf.DistanceFromEdge = 10f;
sec.OddHeader = hf;
sec.EvenHeader = hf;
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(hf);
hf.Paragraphs.Add(text);
Aspose.Pdf.Generator.TextInfo textInfo = new Aspose.Pdf.Generator.TextInfo { FontName = "Helvetica - Bold", FontSize = 12f };
Aspose.Pdf.Generator.Segment s1 = new Aspose.Pdf.Generator.Segment(headerText, textInfo);
s1.TextInfo.FontName = "Helvetica";
text.Segments.Add(s1);
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(pdf);
ImageStamp imageStamp = new ImageStamp(Server.MapPath(ApplicationSettings.IWLogoForPDF));
imageStamp.BottomMargin = 5;
imageStamp.RightMargin = 50;
imageStamp.HorizontalAlignment = HorizontalAlignment.Right;
imageStamp.VerticalAlignment = VerticalAlignment.Bottom;
foreach (Page page in doc.Pages)
{
     page.AddStamp(imageStamp);
}
var svgText = HttpUtility.UrlDecode(svg, Encoding.UTF8);
var svgFile = @"d:\VS 2008\svgfile.svg";
System.IO.File.WriteAllText(svgFile, svgText);
pdf.BindSvg(svgFile);
pdf.Save(@"d:\VS 2008\myPdf.pdf");

Please do the needful.

Regards,
Charan M G


Viewing all articles
Browse latest Browse all 3131

Trending Articles