Exemple #1
0
        public static void BmpsToPdf(List <Bitmap> MyPages, string OcrFile, int MyWidth, int MyHeight)
        {
            {
                /*Document doc = new Document(PageSize.A4);
                 * string imageFile = @"C:\Users\JustinKozlowski\image.pdf";
                 * PdfWriter.GetInstance(doc, new FileStream(imageFile, FileMode.Create));
                 * doc.Open();
                 * iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(image, System.Drawing.Imaging.ImageFormat.Jpeg);
                 * doc.Add(pdfImage);
                 * doc.Close();*/
            }
            //System.Drawing.Image image = System.Drawing.Image.FromFile(@"C:\Users\JustinKozlowski\MyBestPage");
            iText.Kernel.Geom.PageSize bmpSize = new iText.Kernel.Geom.PageSize(MyWidth, MyHeight);
            PdfWriter   writer   = new PdfWriter(OcrFile);
            PdfDocument OcrPdf   = new PdfDocument(writer);
            Document    document = new Document(OcrPdf, bmpSize);

            foreach (Bitmap MyBmp in MyPages)
            {
                byte[] imgBytes = ImageToByte(MyBmp);
                iText.IO.Image.ImageData   imgData = iText.IO.Image.ImageDataFactory.Create(imgBytes);
                iText.Layout.Element.Image img     = new iText.Layout.Element.Image(imgData);
                document.Add(img);
                document.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
            }
            document.Close();
            writer.Close();
        }
Exemple #2
0
        private void BuildCharacterSheet()
        {
            using (PdfDocument _pdfDocument = new PdfDocument(new PdfReader(Main_Sheet), new PdfWriter(_FinishedCharacterSheet)))
            {
                PdfAcroForm form = PdfAcroForm.GetAcroForm(_pdfDocument, true);

                form.GetField("charactername").SetValue($"{_character.CharacterName}").SetFontSizeAutoScale();
                form.GetField("classlevel").SetValue($"{_character.ClassLevel}").SetFontSizeAutoScale();
                form.GetField("background").SetValue($"{_character.Background}").SetFontSize(FontSize(_character.Background.Length) - 1);
                form.GetField("race").SetValue($"{_character.Race}").SetFontSizeAutoScale();
                form.GetField("playername").SetValue($"{_character.PlayerName}").SetFontSizeAutoScale();
                form.GetField("alignment").SetValue($"{_character.Alignment}").SetFontSizeAutoScale();
                form.GetField("xp").SetValue($"{_character.ExperiencePoints}");
                form.GetField("proficencybonus").SetValue($"+{_character.ProficencyBonus}");
                form.GetField("inspiration").SetValue($"{_character.Inspiration}");
                form.GetField("strmodifier").SetValue($"{_character.StrengthModifier}");
                form.GetField("str").SetValue($"{_character.Strength}");
                form.GetField("dexmodifier").SetValue($"{_character.DexterityModifier}");
                form.GetField("dex").SetValue($"{_character.Dexterity}");
                form.GetField("conmodifier").SetValue($"{_character.ConstitutionModifier}");
                form.GetField("con").SetValue($"{_character.Constitution}");
                form.GetField("intmodifier").SetValue($"{_character.IntelligenceModifier}");
                form.GetField("int").SetValue($"{_character.Intelligence}");
                form.GetField("wismodifier").SetValue($"{_character.WisdomModifier}");
                form.GetField("wis").SetValue($"{_character.Wisdom}");
                form.GetField("chamod").SetValue($"{_character.CharismaModifier}");
                form.GetField("cha").SetValue($"{_character.Charisma}");

                if (_character.SaveThrowStrength)
                {
                    form.GetField("savingthrowstr").SetValue($"{_character.SaveThrowStrength}");
                }
                form.GetField("savingthrowmodifierstr").SetValue($"{_character.SaveThrowStrengthModifier}");

                if (_character.ProficencyAthletics)
                {
                    form.GetField("athleticsproficency").SetValue($"{_character.ProficencyAthletics}");
                }
                form.GetField("athleticsmodifier").SetValue($"{_character.AthleticsModifier}");

                if (_character.SaveThrowDexterity)
                {
                    form.GetField("savingthrowdex").SetValue($"{_character.SaveThrowDexterity}");
                }
                form.GetField("savingthrowmodifierdex").SetValue($"{_character.SaveThrowDexterityModifier}");

                if (_character.ProficencyAcrobatics)
                {
                    form.GetField("acrobaticsproficency").SetValue($"{_character.ProficencyAcrobatics}");
                }
                form.GetField("acrobaticsmodifier").SetValue($"{_character.AcobaticsModifier}");

                if (_character.ProficencySlieghtOfHand)
                {
                    form.GetField("sleightofhandproficency").SetValue($"{_character.ProficencySlieghtOfHand}");
                }
                form.GetField("sleightofhandmodifier").SetValue($"{_character.SlieghtOfHandModifier}");

                if (_character.ProficencyStealth)
                {
                    form.GetField("stealthproficency").SetValue($"{_character.ProficencyStealth}");
                }
                form.GetField("stealthmodifier").SetValue($"{_character.StealthModifier}");

                if (_character.SaveThrowConstitution)
                {
                    form.GetField("savingthrowcon").SetValue($"{_character.SaveThrowConstitution}");
                }
                form.GetField("savingthrowmodifiercon").SetValue($"{_character.SaveThrowConstitutionModifier}");

                if (_character.SaveThrowIntelligence)
                {
                    form.GetField("savingthrowint").SetValue($"{_character.SaveThrowIntelligence}");
                }
                form.GetField("savingthrowmodifierint").SetValue($"{_character.SaveThrowIntelligenceModifier}");

                if (_character.ProficencyArcana)
                {
                    form.GetField("arcanaproficency").SetValue($"{_character.ProficencyArcana}");
                }
                form.GetField("arcanamodifier").SetValue($"{_character.ArcanaModifier}");

                if (_character.ProficencyHistory)
                {
                    form.GetField("historyproficency").SetValue($"{_character.ProficencyHistory}");
                }
                form.GetField("historymodifier").SetValue($"{_character.HistoryModifier}");

                if (_character.ProficencyInvestigation)
                {
                    form.GetField("investigationproficency").SetValue($"{_character.ProficencyInvestigation}");
                }
                form.GetField("investigationmodifier").SetValue($"{_character.InvestigationModifier}");

                if (_character.ProficencyNature)
                {
                    form.GetField("natureproficency").SetValue($"{_character.ProficencyNature}");
                }
                form.GetField("naturemodifier").SetValue($"{_character.NatureModifier}");

                if (_character.ProficencyReligion)
                {
                    form.GetField("religionproficency").SetValue($"{_character.ProficencyReligion}");
                }
                form.GetField("religionmodifier").SetValue($"{_character.ReligionModifier}");

                if (_character.SaveThrowWisdom)
                {
                    form.GetField("savingthrowwis").SetValue($"{_character.SaveThrowWisdom}");
                }
                form.GetField("savingthrowmodifierwis").SetValue($"{_character.SavethrowWisdomModifier}");

                if (_character.ProficencyAnimalHandling)
                {
                    form.GetField("animalhandlingproficency").SetValue($"{_character.ProficencyAnimalHandling}");
                }
                form.GetField("animalhandlingmodifier").SetValue($"{_character.AnimalHandlingModifier}");

                if (_character.ProficencyInsight)
                {
                    form.GetField("insightproficency").SetValue($"{_character.ProficencyInsight}");
                }
                form.GetField("insightmodifier").SetValue($"{_character.InsightModifier}");

                if (_character.ProficencyMedicine)
                {
                    form.GetField("medicineproficency").SetValue($"{_character.ProficencyMedicine}");
                }
                form.GetField("medicinemodifier").SetValue($"{_character.MedicineModifier}");

                if (_character.ProficencyPerception)
                {
                    form.GetField("perceptionproficency").SetValue($"{_character.ProficencyPerception}");
                }
                form.GetField("perceptionmodifier").SetValue($"{_character.PerceptionModifer}");

                if (_character.ProficencySurvival)
                {
                    form.GetField("survivalproficency").SetValue($"{_character.ProficencySurvival}");
                }
                form.GetField("survivalmodifier").SetValue($"{_character.SurvivalModifier}");

                if (_character.SaveThrowCharisma)
                {
                    form.GetField("savingthrowcha").SetValue($"{_character.SaveThrowCharisma}");
                }
                form.GetField("savingthrowmodifiercha").SetValue($"{_character.SaveThrowCharismaModifier}");

                if (_character.ProficencyDeception)
                {
                    form.GetField("deceptionproficency").SetValue($"{_character.ProficencyDeception}");
                }
                form.GetField("deceptionmodifier").SetValue($"{_character.DeceptionModifier}");

                if (_character.ProficencyIntimidation)
                {
                    form.GetField("intimidationproficency").SetValue($"{_character.ProficencyIntimidation}");
                }
                form.GetField("intimidationmodifier").SetValue($"{_character.IntimidationModifier}");

                if (_character.ProficencyPerformance)
                {
                    form.GetField("performanceproficency").SetValue($"{_character.ProficencyPerformance}");
                }
                form.GetField("performancemodifier").SetValue($"{_character.PerformanceModifier}");

                if (_character.ProficencyPersuasion)
                {
                    form.GetField("persuasionproficency").SetValue($"{_character.ProficencyPersuasion}");
                }
                form.GetField("persuasionmodifier").SetValue($"{_character.PersuasionModifier}");

                form.GetField("passiveperception").SetValue($"{_character.PassivePerception}");
                form.GetField("ac").SetValue($"{_character.ArmorClass}");
                form.GetField("inititive").SetValue($"+{_character.Inititive}");
                form.GetField("speed").SetValue($"{_character.Speed}");
                form.GetField("hpmax").SetValue($"{_character.HitPointMax}");
                if (_character.HitPointCurrent != _character.HitPointMax)
                {
                    form.GetField("hpcurrent").SetValue($"{_character.HitPointCurrent}");
                }
                form.GetField("hitdicetotal").SetValue($"{_character.HitDiceTotal}").SetFontSize(FontSize(_character.HitDiceTotal.Length) - 6);
                form.GetField("hitdice").SetValue($"{_character.HitDice}").SetFontSize(FontSize(_character.HitDice.Length) - 2);
                form.GetField("weaponname1").SetValue($"{_character.WeaponName1}");
                form.GetField("weaponattackbonus1").SetValue($"{_character.WeaponAttackBonus1}");
                form.GetField("weapondamageandtype1").SetValue($"{_character.WeaponDamageAndType1}");
                form.GetField("weaponname2").SetValue($"{_character.WeaponName2}");
                form.GetField("weaponattackbonus2").SetValue($"{_character.WeaponAttackBonus2}");
                form.GetField("weapondamageandtype2").SetValue($"{_character.WeaponDamageAndType2}");
                form.GetField("weaponname3").SetValue($"{_character.WeaponName3}");
                form.GetField("weaponattackbonus3").SetValue($"{_character.WeaponAttackBonus3}");
                form.GetField("weapondamageandtype3").SetValue($"{_character.WeaponDamageAndType3}");
                form.GetField("attacksandspellcasting").SetValue($"{_character.AttackAndSpellCasting}");
                form.GetField("traits").SetValue($"{_character.PersonalityTraits}").SetFontSize(FontSize(_character.PersonalityTraits.Length));
                form.GetField("ideals").SetValue($"{_character.PersonalityIdeals}").SetFontSize(FontSize(_character.PersonalityIdeals.Length));
                form.GetField("bonds").SetValue($"{_character.PersonalityBonds}").SetFontSize(FontSize(_character.PersonalityBonds.Length));
                form.GetField("flaws").SetValue($"{_character.PersonalityFlaws}").SetFontSize(FontSize(_character.PersonalityFlaws.Length));
                form.GetField("featuresandtraits1").SetValue($"{_character.FeaturesAndTraits1}").SetFontSize(FontSize(_character.FeaturesAndTraits1.Length));
                form.GetField("proficienciesandlanguages").SetValue($"{_character.ProficiencesAndLanguages}").SetFontSize(FontSize(_character.ProficiencesAndLanguages.Length) + 1);
                form.GetField("equipment1").SetValue($"{_character.Equipment1}").SetFontSize(FontSize(_character.Equipment1.Length) + 1);
                form.GetField("passiveperception").SetValue($"{_character.PassivePerception}");

                using (PdfDocument _working = new PdfDocument(new PdfReader(Details_Sheet), new PdfWriter(Working_Sheet)))
                {
                    PdfAcroForm workingform = PdfAcroForm.GetAcroForm(_working, true);
                    workingform.GetField("charactername2").SetValue($"{_character.CharacterName}").SetFontSizeAutoScale();
                    workingform.GetField("age").SetValue($"{_character.Age}").SetFontSizeAutoScale();
                    workingform.GetField("height").SetValue($"{_character.Height}").SetFontSizeAutoScale();
                    workingform.GetField("weight").SetValue($"{_character.Weight}").SetFontSizeAutoScale();
                    workingform.GetField("eyes").SetValue($"{_character.Eyes}").SetFontSizeAutoScale();
                    workingform.GetField("skin").SetValue($"{_character.Skin}").SetFontSizeAutoScale();
                    workingform.GetField("hair").SetValue($"{_character.Hair}").SetFontSizeAutoScale();
                    workingform.GetField("allies").SetValue($"{_character.Allies}");
                    workingform.GetField("factionname").SetValue($"{_character.FactionName}").SetFontSizeAutoScale();
                    workingform.GetField("backstory1").SetValue($"{_character.BackStory}").SetFontSize(FontSize(_character.BackStory.Length) + 1);
                    workingform.GetField("featsandtraits2").SetValue($"{_character.FeatsAndTraits2}").SetFontSize(FontSize(_character.FeatsAndTraits2.Length) + 1);
                    workingform.GetField("equipment2").SetValue($"{_character.Equipment2}").SetFontSize(FontSize(_character.Equipment2.Length) + 1);

                    if (!string.IsNullOrEmpty(Character_Image) && File.Exists(Character_Image))
                    {
                        iText.IO.Image.ImageData imageData = ImageDataFactory.Create(Character_Image);
                        Image    image    = new Image(imageData).ScaleToFit(145, 200).SetFixedPosition(1, 45, 450);
                        Document document = new Document(_working);
                        document.Add(image);
                    }

                    if (!string.IsNullOrEmpty(Faction_Image) && File.Exists(Faction_Image))
                    {
                        iText.IO.Image.ImageData imageData = ImageDataFactory.Create(Faction_Image);
                        Image    image    = new Image(imageData).ScaleToFit(106, 106).SetFixedPosition(1, 453, 510);
                        Document document = new Document(_working);
                        document.Add(image);
                    }
                }
                using (PdfDocument _details = new PdfDocument(new PdfReader(Working_Sheet)))
                {
                    _pdfDocument.AddPage(_details.GetPage(1).CopyTo(_pdfDocument));
                }
                FileInfo file = new FileInfo(Working_Sheet);
                file.Delete();

                for (int i = 0; i < _character.SpellCasting.Count; i++)
                {
                    using (PdfDocument _spell = new PdfDocument(new PdfReader(Spells_Sheet), new PdfWriter(Working_Sheet)))
                    {
                        WriteSpells(_spell, _character.SpellCasting[i]);
                    }
                    PdfDocument _spells = new PdfDocument(new PdfReader(Working_Sheet));
                    _pdfDocument.AddPage(_spells.GetPage(1).CopyTo(_pdfDocument));
                    _spells.Close();
                }
                file = new FileInfo(Working_Sheet);
                file.Delete();
            }
        }
Exemple #3
0
 protected internal virtual void AddFrame(ImageData frame)
 {
     frames.Add(frame);
 }