using visual studio .net mvc @{ ViewData["Title"] = "View PDF Pages"; var imageUrls = ViewData["ImageUrls"] as List<string>; var fileName = ViewData["FileName"] as string; } <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>@ViewData["Title"]</title> <link rel="stylesheet" type="text/css" href="~/css/turn.css"> <link rel="stylesheet" type="text/css" href="~/css/site.css"> </head> <body> <a href="@Url.Action("DownloadPdf", "Home", new { fileName })" class="download-btn">Download PDF</a> <div id="flipbook"> @for (int i = 0; i < imageUrls.Count; i++) { <div class="page" style="left:@((i % 2 == 0) ? "0" : "50%")"> <img src="@imageUrls[i]" alt="Page @((i / 2) + 1)"> </div> } <div class="arrow arrow-left" id="prevBtn">❮</div> <div class="arrow arrow-right" id="nextBtn">❯</div> </div> <script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script> <script> $(document).ready(function () { const pages = $('.page'); let currentPage = 0; function showPages(index) { pages.removeClass('flipped'); for (let i = 0; i <= index * 2; i++) { if (i % 2 !== 0) { pages.eq(i).addClass('flipped'); } } } $('#nextBtn').click(function () { if (currentPage < Math.floor(pages.length / 2)) { currentPage++; showPages(currentPage); } }); $('#prevBtn').click(function () { if (currentPage > 0) { currentPage--; showPages(currentPage); } }); pages.forEach((page, index) => { // Set the z-index page.style.zIndex = pages.length - index; showPages(currentPage); }); </script> </body> </html> css #flipbook { width: 800px; /* Adjust width to accommodate two pages */ height: 600px; /* Adjust height as needed */ margin: 20px auto; position: relative; perspective: 1000px; } .page { width: 50%; /* Each page takes half of the container */ height: 100%; position: absolute; top: 0; left: 0; transform-origin: left; transition: transform 0.5s ease; backface-visibility: visible; transform-style: preserve-3d; /* Ensures proper 3D perspective */ } .page img { width: 100%; height: 100%; } .page.flipped { transform: rotateY(-180deg); /* Rotate to the back side */ z-index: 2; } .arrow { position: absolute; top: 50%; transform: translateY(-50%); font-size: 36px; cursor: pointer; z-index: 1000; color: #333; } .arrow-left { left: 10px; } .arrow-right { right: 10px; } .nav-buttons { text-align: center; margin-top: 20px; } .download-btn { display: block; margin: 20px; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)