public MemoryStream CreateOfflinePDF(ApplicationForm applicationForm, ApplicationFormDocumentType docType)
{
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section PasswordSection = pdf.Sections.Add();
PasswordSection.TextInfo.FontName = "Helvetica";
SetPageHeader(PasswordSection, "Form Submission");
Text passwordText = new Text("
To submit the information in this form please supply your Bupa Survey system credentials and click the Save Button.
The details in your online form will be updated.
");
passwordText.TextInfo.FontName = "Helvetica";
passwordText.IsHtmlTagSupported = true;
PasswordSection.Paragraphs.Add(passwordText);
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
TextInfo info = new TextInfo();
info.FontName = "Helvetica";
tab1.DefaultCellTextInfo = info;
MarginInfo margin = new MarginInfo();
margin.Bottom = 2;
margin.Top = 2;
margin.Inner = 0;
tab1.DefaultCellPadding = margin;
CreateUserNameAndPassword(tab1, PasswordSection);
Security security = new Security();
security.IsAnnotationsModifyingAllowed = true;
security.IsContentsModifyingAllowed = true;
security.IsCopyingAllowed = true;
security.IsScreenReadersAllowed = true;
security.IsPrintingAllowed = true;
security.IsFormFillingAllowed = true;
pdf.Security = security;
MemoryStream stream = new MemoryStream();
pdf.Save(stream);
FormEditor fe = new FormEditor(stream, stream);
fe.AddSubmitBtn("Submit", pdf.PageCount , "Save", string.Format(@"{0}/en/Submit/Render/SaveOfflineDocument?applicationformid={1}",Settings.General.PortalURL, applicationForm.ID.ToString()), 500, 400, 550, 425);
fe.Save(stream);
return stream;
}
private void SetPageHeader(Section sec, string name)
{
Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec);
// add the text object to Paragraphs collection of section
sec.Paragraphs.Add(t1);
Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
// add the contents for Segment1
seg1.Content = string.Format("{0}", name);
// Specify the Font fore color for segement1
seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("White");
// specify the font size information for segment1
seg1.TextInfo.FontSize = 20;
// Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
t1.Opacity = 1F;
// add the segment to segments collection of Text1
t1.Segments.Add(seg1);
t1.ZIndex = 1;
//Tiff image cover the underlayer text
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec);
image1.ImageInfo.File = string.Format(@"{0}\Untitled.png", Settings.General.AppDataPath);
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;
image1.ZIndex = 0;
// Create a Floating Box object that will hold image file
Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(60, 21);
// add Floating box to paragraphs collection of Section1
sec.Paragraphs.Add(box1);
// Specify the left margin of FloatingBox1
box1.Left = -100;
// Specify the Top margin of FloatingBox1
box1.Top = -12;
box1.ZIndex = 0;
box1.Paragraphs.Add(image1);
Text text = new Text("
");
text.IsHtmlTagSupported = true;
sec.Paragraphs.Add(text);
}
private static void CreateUserNameAndPassword(Table tab1, Section PasswordSection)
{
Aspose.Pdf.Generator.Row r1 = tab1.Rows.Add();
Aspose.Pdf.Generator.Row r2 = tab1.Rows.Add();
Aspose.Pdf.Generator.Cell c1 = r1.Cells.Add("User Name:");
c1.FitWidth = 100;
Aspose.Pdf.Generator.Cell c2 = r1.Cells.Add("");
c2.Padding.Left = 30;
c2.FitWidth = 150;
c2.Paragraphs[0].ID = "USERNAME";
Aspose.Pdf.Generator.Cell c3 = r2.Cells.Add("Password:");
c3.FitWidth = 100;
Aspose.Pdf.Generator.Cell c4 = r2.Cells.Add("");
c4.Padding.Left = 30;
c4.FitWidth = 150;
c4.Paragraphs[0].ID = "PASSWORD";
PasswordSection.Paragraphs.Add(tab1);
Aspose.Pdf.Generator.FormField textbox = new Aspose.Pdf.Generator.FormField();
textbox.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Text;
textbox.FieldName = "PASSWORD";
textbox.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
textbox.ReferenceParagraphID = "PASSWORD";
textbox.TextIsPassword = true;
textbox.TextFontSize = 10;
textbox.FormWidth = 150;
textbox.FormHeight = 15;
c4.Paragraphs.Add(textbox);
Aspose.Pdf.Generator.FormField textbox2 = new Aspose.Pdf.Generator.FormField();
textbox2.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Text;
textbox2.FieldName = "USERNAME";
textbox2.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
textbox2.ReferenceParagraphID = "USERNAME";
textbox2.TextFontSize = 10;
textbox2.FormWidth = 150;
textbox2.FormHeight = 15;
c2.Paragraphs.Add(textbox2);
}